package com.kaili.basic.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.kaili.basic.pojo.entity.SystemParam;
import com.kaili.basic.mapper.SystemParamMapper;
import com.kaili.basic.service.SystemParamService;
import com.kaili.common.util.LoginDetailUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created by renzhikun on 18-9-28.
 */
@Service
public class SystemParamServiceImpl implements SystemParamService{

    @Autowired
    private SystemParamMapper systemParamMapper;

    @Override
    public void addSystemParam(SystemParam systemParam) {
        Integer uid = LoginDetailUtils.getCurrentEmployeeId();
        if (uid != null) {
            systemParam.setCreateBy(uid.longValue());
            systemParam.setCreateTime(new Date());
            systemParamMapper.addSystemParam(systemParam);
        }

    }

    @Override
    public void updateSystemParam(SystemParam systemParam) {
        Integer uid = LoginDetailUtils.getCurrentEmployeeId();
        if (uid != null) {
            systemParam.setModifyBy(uid.longValue());
            systemParam.setModifyTime(new Date());
            systemParamMapper.updateSystemParam(systemParam);
        }
    }

    @Override
    public void deleteSystemParam(Integer paramId) {
        systemParamMapper.deleteSystemParam(paramId);
    }

    @Override
    public Page<SystemParam> querySystemParam(Page<SystemParam> page, SystemParam systemParam) {
        List<SystemParam> list = systemParamMapper.querySystemParam(page, systemParam);
        return page.setRecords(list);
    }

    @Override
    public SystemParam getSystemParam(SystemParam systemParam) {
        return systemParamMapper.getSystemParam(systemParam);
    }

}
